Skip to contentSkip to conversation

Change in openvpn[master]: Fix warnings about conversion from int to unsigned char/uint8_t

Openvpn-devel In review plaisthos (Code Review) 2 participants 6 messages Oct 29, 2025 – Oct 30, 2025 1 message not in the archive

lore
Share & tools
lore

A message that is not in the archive (sent off-list or not yet received): gerrit.1761745430000.I648ee99b1152b1248d1b3e64af7679ab99f1388f@...2715...

#1 lore raw

Attention is currently required from: flichtenheld.

Hello flichtenheld,

I'd like you to do a code review.
Please visit

    http://gerrit.openvpn.net/c/openvpn/+/1328?usp=email

to review the following change.

Change subject: Fix warnings about conversion from int to unsigned char/uint8_t
......................................................................

Fix warnings about conversion from int to unsigned char/uint8_t

When compiling with cmake -DCMAKE_BUILD_TYPE=ASAN under Ubuntu 25.10 (gcc 15.2.0).

Explicitly cast these instances to uint8_t/unssigned char to silence this warning.

Change-Id I648ee99b1152b1248d1b3e64af7679ab99f1388f

---
M src/openvpn/httpdigest.c
M src/openvpn/mroute.c

2 files changed, 3 insertions(+), 3 deletions(-)

git pull ssh://gerrit.openvpn.net:29418/openvpn refs/changes/28/1328/1

src/openvpn/httpdigest.c +2 -2
index be20638..3e6520a 100644
@@ -46,7 +46,7 @@
         }
         else
         {
-            Hex[i * 2] = (j + 'a' - 10);
+            Hex[i * 2] = (unsigned char)(j + 'a' - 10);
         }
         j = Bin[i] & 0xf;
         if (j <= 9)
@@ -55,7 +55,7 @@
         }
         else
         {
-            Hex[i * 2 + 1] = (j + 'a' - 10);
+            Hex[i * 2 + 1] = (unsigned char)(j + 'a' - 10);
         }
     }
     Hex[HASHHEXLEN] = '\0';
src/openvpn/mroute.c +1 -1
index b50d48f..d17902f 100644
@@ -337,7 +337,7 @@
             }
             else
             {
-                ma->v6.addr.s6_addr[byte--] &= (0xFF << bits_to_clear);
+                ma->v6.addr.s6_addr[byte--] &= (uint8_t)(0xFF << bits_to_clear);
                 bits_to_clear = 0;
             }
         }

--
To view, visit http://gerrit.openvpn.net/c/openvpn/+/1328?usp=email
To unsubscribe, or for help writing mail filters, visit http://gerrit.openvpn.net/settings?usp=email

Gerrit-MessageType: newchange
Gerrit-Project: openvpn
Gerrit-Branch: master
Gerrit-Change-Id: I648ee99b1152b1248d1b3e64af7679ab99f1388f
Gerrit-Change-Number: 1328
Gerrit-PatchSet: 1
Gerrit-Owner: plaisthos <[email protected]...>
Gerrit-Reviewer: flichtenheld <[email protected]...>
Gerrit-CC: openvpn-devel <[email protected]>
Gerrit-Attention: flichtenheld <[email protected]...>

#2 lore raw
In reply to a message not in the archive

Attention is currently required from: flichtenheld, plaisthos.

cron2 has posted comments on this change by plaisthos. ( http://gerrit.openvpn.net/c/openvpn/+/1328?usp=email )

Change subject: Fix warnings about conversion from int to unsigned char/uint8_t
......................................................................

Patch Set 1: Code-Review+2

--
To view, visit http://gerrit.openvpn.net/c/openvpn/+/1328?usp=email
To unsubscribe, or for help writing mail filters, visit http://gerrit.openvpn.net/settings?usp=email

Gerrit-MessageType: comment
Gerrit-Project: openvpn
Gerrit-Branch: master
Gerrit-Change-Id: I648ee99b1152b1248d1b3e64af7679ab99f1388f
Gerrit-Change-Number: 1328
Gerrit-PatchSet: 1
Gerrit-Owner: plaisthos <[email protected]...>
Gerrit-Reviewer: cron2 <[email protected]...>
Gerrit-Reviewer: flichtenheld <[email protected]...>
Gerrit-CC: openvpn-devel <[email protected]>
Gerrit-Attention: plaisthos <[email protected]...>
Gerrit-Attention: flichtenheld <[email protected]...>
Gerrit-Comment-Date: Thu, 30 Oct 2025 19:38:13 +0000
Gerrit-HasComments: No
Gerrit-Has-Labels: Yes

#3 lore raw

PATCH 1/1 Fix warnings about conversion from int to unsigned char/uint8_t

In reply to a message not in the archive

From: Arne Schwabe <[email protected]...>

When compiling with cmake -DCMAKE_BUILD_TYPE=ASAN under Ubuntu 25.10 (gcc 15.2.0).

Explicitly cast these instances to uint8_t/unssigned char to silence this warning.

Change-Id I648ee99b1152b1248d1b3e64af7679ab99f1388f

Gerrit URL: https://gerrit.openvpn.net/c/openvpn/+/1328
---

This change was reviewed on Gerrit and approved by at least one developer. I request to merge it to master.

Gerrit URL: https://gerrit.openvpn.net/c/openvpn/+/1328
This mail reflects revision 1 of this Change.

Acked-by according to Gerrit (reflected above):
Gert Doering <[email protected]...>

src/openvpn/httpdigest.c +2 -2
index be20638..3e6520a 100644
@@ -46,7 +46,7 @@
         }
         else
         {
-            Hex[i * 2] = (j + 'a' - 10);
+            Hex[i * 2] = (unsigned char)(j + 'a' - 10);
         }
         j = Bin[i] & 0xf;
         if (j <= 9)
@@ -55,7 +55,7 @@
         }
         else
         {
-            Hex[i * 2 + 1] = (j + 'a' - 10);
+            Hex[i * 2 + 1] = (unsigned char)(j + 'a' - 10);
         }
     }
     Hex[HASHHEXLEN] = '\0';
src/openvpn/mroute.c +1 -1
index b50d48f..d17902f 100644
@@ -337,7 +337,7 @@
             }
             else
             {
-                ma->v6.addr.s6_addr[byte--] &= (0xFF << bits_to_clear);
+                ma->v6.addr.s6_addr[byte--] &= (uint8_t)(0xFF << bits_to_clear);
                 bits_to_clear = 0;
             }
         }
#4 lore raw

[Openvpn-devel] [PATCH applied] Re: Fix warnings about conversion from int to unsigned char/uint8_t

Looks reasonable. I do not have an ubuntu 25 system yet to test, but on the older boxes this does not warn either way, and the casts are safe. BB is happy.

Your patch has been applied to the master branch.

commit e7df832354fd476defe6a0fb35ab1aa05314c5e3

Author: Arne Schwabe
Date:   Thu Oct 30 20:38:20 2025 +0100
     Fix warnings about conversion from int to unsigned char/uint8_t

     Signed-off-by: Arne Schwabe <[email protected]...>
     Acked-by: Gert Doering <[email protected]...>
     Gerrit URL: https://gerrit.openvpn.net/c/openvpn/+/1328
     Message-Id: <[email protected]...>
     URL: https://www.mail-archive.com/[email protected]/msg34065.html
     Signed-off-by: Gert Doering <[email protected]...>

--
kind regards,

Gert Doering

#5 lore raw
In reply to a message not in the archive

cron2 has uploaded a new patch set (#2) to the change originally created by plaisthos. ( http://gerrit.openvpn.net/c/openvpn/+/1328?usp=email )

The following approvals got outdated and were removed:
Code-Review+2 by cron2

Change subject: Fix warnings about conversion from int to unsigned char/uint8_t
......................................................................

Fix warnings about conversion from int to unsigned char/uint8_t

When compiling with cmake -DCMAKE_BUILD_TYPE=ASAN under Ubuntu 25.10 (gcc 15.2.0).

Explicitly cast these instances to uint8_t/unssigned char to silence this warning.

Change-Id I648ee99b1152b1248d1b3e64af7679ab99f1388f

Gerrit URL: https://gerrit.openvpn.net/c/openvpn/+/1328
Message-Id: <[email protected]...>
URL: https://www.mail-archive.com/[email protected]/msg34065.html

---
M src/openvpn/httpdigest.c
M src/openvpn/mroute.c

2 files changed, 3 insertions(+), 3 deletions(-)

git pull ssh://gerrit.openvpn.net:29418/openvpn refs/changes/28/1328/2

src/openvpn/httpdigest.c +2 -2
index be20638..3e6520a 100644
@@ -46,7 +46,7 @@
         }
         else
         {
-            Hex[i * 2] = (j + 'a' - 10);
+            Hex[i * 2] = (unsigned char)(j + 'a' - 10);
         }
         j = Bin[i] & 0xf;
         if (j <= 9)
@@ -55,7 +55,7 @@
         }
         else
         {
-            Hex[i * 2 + 1] = (j + 'a' - 10);
+            Hex[i * 2 + 1] = (unsigned char)(j + 'a' - 10);
         }
     }
     Hex[HASHHEXLEN] = '\0';
src/openvpn/mroute.c +1 -1
index b50d48f..d17902f 100644
@@ -337,7 +337,7 @@
             }
             else
             {
-                ma->v6.addr.s6_addr[byte--] &= (0xFF << bits_to_clear);
+                ma->v6.addr.s6_addr[byte--] &= (uint8_t)(0xFF << bits_to_clear);
                 bits_to_clear = 0;
             }
         }

--
To view, visit http://gerrit.openvpn.net/c/openvpn/+/1328?usp=email
To unsubscribe, or for help writing mail filters, visit http://gerrit.openvpn.net/settings?usp=email

Gerrit-MessageType: newpatchset
Gerrit-Project: openvpn
Gerrit-Branch: master
Gerrit-Change-Id: I648ee99b1152b1248d1b3e64af7679ab99f1388f
Gerrit-Change-Number: 1328
Gerrit-PatchSet: 2
Gerrit-Owner: plaisthos <[email protected]...>
Gerrit-Reviewer: cron2 <[email protected]...>
Gerrit-Reviewer: flichtenheld <[email protected]...>
Gerrit-CC: openvpn-devel <[email protected]>

#6 lore raw
In reply to a message not in the archive

cron2 has submitted this change. ( http://gerrit.openvpn.net/c/openvpn/+/1328?usp=email )

Change subject: Fix warnings about conversion from int to unsigned char/uint8_t
......................................................................

Fix warnings about conversion from int to unsigned char/uint8_t

When compiling with cmake -DCMAKE_BUILD_TYPE=ASAN under Ubuntu 25.10 (gcc 15.2.0).

Explicitly cast these instances to uint8_t/unssigned char to silence this warning.

Change-Id I648ee99b1152b1248d1b3e64af7679ab99f1388f

Gerrit URL: https://gerrit.openvpn.net/c/openvpn/+/1328
Message-Id: <[email protected]...>
URL: https://www.mail-archive.com/[email protected]/msg34065.html

---
M src/openvpn/httpdigest.c
M src/openvpn/mroute.c

2 files changed, 3 insertions(+), 3 deletions(-)
src/openvpn/httpdigest.c +2 -2
index be20638..3e6520a 100644
@@ -46,7 +46,7 @@
         }
         else
         {
-            Hex[i * 2] = (j + 'a' - 10);
+            Hex[i * 2] = (unsigned char)(j + 'a' - 10);
         }
         j = Bin[i] & 0xf;
         if (j <= 9)
@@ -55,7 +55,7 @@
         }
         else
         {
-            Hex[i * 2 + 1] = (j + 'a' - 10);
+            Hex[i * 2 + 1] = (unsigned char)(j + 'a' - 10);
         }
     }
     Hex[HASHHEXLEN] = '\0';
src/openvpn/mroute.c +1 -1
index b50d48f..d17902f 100644
@@ -337,7 +337,7 @@
             }
             else
             {
-                ma->v6.addr.s6_addr[byte--] &= (0xFF << bits_to_clear);
+                ma->v6.addr.s6_addr[byte--] &= (uint8_t)(0xFF << bits_to_clear);
                 bits_to_clear = 0;
             }
         }

--
To view, visit http://gerrit.openvpn.net/c/openvpn/+/1328?usp=email
To unsubscribe, or for help writing mail filters, visit http://gerrit.openvpn.net/settings?usp=email

Gerrit-MessageType: merged
Gerrit-Project: openvpn
Gerrit-Branch: master
Gerrit-Change-Id: I648ee99b1152b1248d1b3e64af7679ab99f1388f
Gerrit-Change-Number: 1328
Gerrit-PatchSet: 2
Gerrit-Owner: plaisthos <[email protected]...>
Gerrit-Reviewer: cron2 <[email protected]...>
Gerrit-Reviewer: flichtenheld <[email protected]...>
Gerrit-CC: openvpn-devel <[email protected]>